//
//  ShowMytext.m
//  AFN封装demol
//
//  Created by dllo on 15/11/25.
//  Copyright © 2015年 大远. All rights reserved.
//

#import "ShowMytext.h"

@implementation ShowMytext


+ (instancetype)shareSingleton{
    static ShowMytext *model;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        model = [[ShowMytext alloc]init];
    });
    return model;
}


+ (void)showHUDTextWithTitle:(NSString *)str View:(UIView *)view{
    
    MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view];
    [view addSubview:hud];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = str;
    [hud show:YES];
    hud.alpha = 0;
    [UIView animateWithDuration:1 animations:^{
        hud.alpha = 1;
        
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.7 animations:^{
            hud.alpha = 0;
        } completion:^(BOOL finished) {
            
            [hud hide:YES];
            [hud removeFromSuperview];
            
        }];
        
    }];
    
}


+ (void)showHUDloadView:(UIView *)view{
    ShowMytext *load = [ShowMytext shareSingleton];
    load.Myhud = [[MBProgressHUD alloc]initWithView:view];
    [view addSubview:load.Myhud];
    load.Myhud.labelText = @"稍等瞬息...";
    [load.Myhud show:YES];
}

+ (void)showHUDloadView:(UIView *)view text:(NSString *)text{
    ShowMytext *load = [ShowMytext shareSingleton];
    load.Myhud = [[MBProgressHUD alloc]initWithView:view];
    [view addSubview:load.Myhud];
    load.Myhud.labelText = text;
    [load.Myhud show:YES];
}

+ (void)hiddHUDloadView{
    ShowMytext *load = [ShowMytext shareSingleton];
    [load.Myhud hide:YES];
    [load.Myhud removeFromSuperview];
}
+ (void)showAlertViewTitlt:(NSString *)title message:(NSString *)message selector:(id)aSelector Block:(void (^)())block{
    UIAlertController *alertcontroller = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        block();
    }];
    [alertcontroller addAction:cancelAction];
    [aSelector presentViewController:alertcontroller animated:YES completion:nil];
}

@end
